<template>
<!--套餐使用情况-->
<view class="community">
	<view class="head_bg"></view>
	<view class="big_box" style="margin-top:-180rpx;">
		<view class="package" style="margin-top:30rpx;">
			<view class="flex">
				<view class="flex-sub">
					<view class="time_name text-white">包月按次畅充套餐</view>
					<view class="text-white time_mon">¥<text>50</text></view>
				</view>
				<view class="flex-sub text-right">
					<view class="time_time text-white">2021-05-25至2021-05-26</view>
					<view class="time_add margin-top-xs time_add_color">富江恒大三水成晓旭</view>
					<view class="time_add time_add_color">仅限本小区使用</view>
				</view>
			</view>
			<view class="operating_box_inner padding-top-sm">
				<view class="money_details_inner money_details_inner1">
					<view class="money_details_number time_add_color">1</view>
					<view class="money_details_text time_add_color">总充电(次)</view>
				</view>
				<view class="detail_br" style="border-left: 1rpx solid #EDEDED;position: relative;top: 25rpx;"></view>
				<view class="money_details_inner money_details_inner1">
					<view class="money_details_number time_add_color">4</view>
					<view class="money_details_text time_add_color">每次充电（小时）</view>
				</view>
				<view class="detail_br" style="border-left: 1rpx solid #EDEDED;position: relative;top: 25rpx;"></view>
				<view class="money_details_inner money_details_inner1">
					<view class="money_details_number time_add_color">3</view>
					<view class="money_details_text time_add_color">剩余（次）</view>
				</view>
			</view>
		</view>
		<view class="operating_box">
			<view class="flex solid">
				<view class="flex-treble text-left margin-left-sm">
					<view class="text-black text-df padding-top-sm">
						终端编号：07 左
					</view>
					<view class="text-black text-df padding-top-sm padding-bottom-sm">
						充电时间：202105-24 17:00
					</view>
				</view>
			</view>
		</view>
		<view style="height:100rpx;"></view>
		<view v-if="list.length==0" class="margin-top-lg text-center">
			<image src='../../../common/img/no_data.png' style="width:275rpx;height:312rpx;"></image>
		</view>
		<view v-if="list.length>0" class="text-black text-df text-center bg-white padding-sm padding-left-lg be-gray">
			{{loadingTxt}} 共({{list.length}}条记录)
		</view>
	</view>
</view>
</template>

<script>
	let page=1,timer=null
	export default {
		data() {
			return {
				info:'',
				tabIndex: 1,
				istrue: true,
				list:[],
				loadingTxt:'加载更多',
			}
		},
		onShow() {
			page=1;
			this.gatlist();
		},
		methods: {
			tabSelect(e) {
				page=1;
				this.loadingTxt="加载更多"
				this.tabIndex = e.currentTarget.dataset.id;
				this.gatlist();
			},
			gatlist(){
				let that=this;
				let url;
				if(this.tabIndex==1){
					url="profit/v1/day";
				}else if(this.tabIndex==2){
					url="profit/v1/month";
				}
				that.http.tokenreq({
					url:url,
					data:{"pageindex":page}
				}).then((res) => {
					console.log("res="+JSON.stringify(res));
					let e=res.data;
					if(e.code==0 && e.success){
						let list=e.rows;
						console.log("list="+JSON.stringify(list));
						that.list=list;
						page++;
					}else{
						uni.showModal({
							content:e.message,
							showCancel:false,
						})
					}
				})
			},
			getmorelist(){
				this.loadingTxt='加载中'
				let that=this;
				let url;
				if(this.tabIndex==1){
					url="profit/v1/day";
				}else if(this.tabIndex==2){
					url="profit/v1/month";
				}
				that.http.tokenreq({
					url:url,
					data:{"pageindex":page}
				}).then((res) => {
					console.log("res="+JSON.stringify(res));
					let e=res.data;
					if(e.code==0 && e.success){
						if(e.rows.length==0){
							that.loadingTxt="已经加载全部";
							return;
						}
						that.list=that.list.concat(e.rows);
						page++;
					}else{
						uni.showModal({
							content:e.message,
							showCancel:false,
						})
					}
				})
			},
			onReachBottom() {
				//阻止重复加载
				if(timer !== null){
					clearTimeout(timer)
				}
				timer=setTimeout(()=>this.getmorelist(),500)
			},
		}
	}
</script>
<style>
	.ele_title_inner{
		color: #FFFFFF;
		font-size:36rpx;
	}
	.package{
		background-image: url(../../../common/img/ka2.png);
		background-size: 100% 100%;
		width: 100%;
		height: 450rpx;
	}
	.time_name{
		padding: 20rpx 0 0rpx 40rpx;
		font-size: 34rpx;
	}
	.time_mon{
		padding: 0 0 0 40rpx;
		font-size: 50rpx;
	}
	.time_time{
		padding: 70rpx 30rpx 0 0rpx;
	}
	.time_add{
		padding: 0rpx 30rpx 0 0;
	}
	.time_add_color{
		color:#8C6B22
	}
	.operating_box{
		margin-top: 10rpx;
		padding-bottom: 0;
		border-radius: 20rpx;
	}
	.solid::after {
	    border: none;
	}
</style>